/* linear_2d_projector.h */

#ifndef DODO_LINEAR_2D_PROJECTOR_H
#define DODO_LINEAR_2D_PROJECTOR_H

#include <dodo_plot/kernel/plotfwd.h>
#include <dodo_plot/kernel/basic_elements.h>

namespace dodo_plot
{

template<class X_T, class Y_T>
class Linear_2d_Projector
{
public:
	typedef X_T x_type;
	typedef Y_T y_type;
	typedef Linear_2d_Projector<X_T, Y_T> proj_type;

	Point operator() (x_type x, y_type y) const
	{
		return Point(
			(x - x_min_) * x_scale_,
			h_ - (y - y_min_) * y_scale_
			);
	}

	double width() const { return w_; }
	double height() const { return h_; }

public:
	Linear_2d_Projector(
		const x_type& x_min, const x_type& x_max,
		const y_type& y_min, const y_type& y_max
		)
		:
		x_min_(x_min), y_min_(y_min),
		w_(1.0), h_(1.0),
		x_orig_(0.0), y_orig_(1.0),
		x_scale_( w_ / (x_max - x_min) ),
		y_scale_( h_ / (y_max - y_min) )
	{ }



private:

	x_type x_min_;
	y_type y_min_; 
	double w_, h_;
	double x_orig_, y_orig_;
	double x_scale_, y_scale_;

//	bool reverse_y;

};

}

#endif //DODO_LINEAR_2D_PROJECTOR_H

